/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server;

import commom.VirtualMachine;
import java.util.ArrayList;
import java.util.UUID;
import simulation.VMTask;

/**
 * This class is responsible to describe a test.
 * Each object of this class will have one slave with one
 * VMTask object associated.
 * Long story short, the TestSpec associates one Virtual
 * Machine available from the Slave VM list with one
 * time distribution of load genaration
 *
 * Note about this class format:
 *  It seens 'redundant' to store the slave here along
 *  with the virtual machine specification, since the
 *  virtual machine is on a list inside the slave, but
 *  in order to later send a XML file with this specifi-
 *  cation, it's necessary to know the IP address of the
 *  slave, so by sotoring the pointer to slave heve saves
 *  some search time in the ArrayList of slaves.
 * @author gravena
 * @see VMTask
 */
public class TestSpec {
    
    private Slave slave;    
    private UUID vm; /* UUID of the virtual machine */
    private VMTask task;
    private UUID id; /* ID of the Test that this TestSpec belongs to */

    public TestSpec(Slave slave, UUID vm, VMTask task, UUID id) {
        this.vm = vm;
        this.task = task;
        this.id = id;
        this.slave = slave;
    }    
    
    public VirtualMachine getVm() {
        ArrayList<VirtualMachine> list = this.slave.getVMList();
        for(int i=0;i<list.size();i++) {
            if(list.get(i).getUUID().compareTo(vm) == 0) {
                return list.get(i);
            }
        }
        
        return null;
    }
    

    public VMTask getTask() {
        return task;
    }

    public void setTask(VMTask task) {
        this.task = task;
    }

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }                    

    public Slave getSlave() {
        return slave;
    }        
       
    public static TestSpec search(ArrayList<TestSpec> list, UUID vm, VMTask task, UUID id) {
                
        
        return null;
    }
    

    
}
